package com.xlhj.rabbit.receive;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: caijliu
 * @Date: 03/09/2021 9:32
 * @Description TODO
 * @Vsersion: 0.0.1
 */
@Component
public class TopicConsumer {

    private static final String TOPIC_QUEUE_NAME_A = "topic-queue-A";
    private static final String TOPIC_QUEUE_NAME_B = "topic-queue-B";
    private static Logger logger = LoggerFactory.getLogger(TopicConsumer.class);

    @RabbitListener(queues = TOPIC_QUEUE_NAME_A)
    public void receiveMsgA(Message message) {
        String msg = new String(message.getBody());
        logger.info("接收到队列topic.queueA消息：{}", msg);
    }

    @RabbitListener(queues = TOPIC_QUEUE_NAME_B)
    public void receiveMsgB(Message message) {
        String msg = new String(message.getBody());
        logger.info("接收到队列topic.queueB消息：{}", msg);
    }
}
